<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">
    <body>
        <ui:composition template="../templates/default3.xhtml">  
            <ui:define name="content">
                <h:form binding="#{jobManagerBean.loadAddJob}">
                    <p:panel header="Job Information" id="addJob">
                        <p:messages id="error"/>
                        <table >
                            <tr>
                                <td width="135px"> User ID:</td>
                                <td>
                                    <b><h:outputText id="userId" value=" #{jobManagerBean.userId}"/></b>
                                </td>
                            </tr>
                            <tr>
                                <td width="135px"> Company:</td>
                                <td>
                                    <b><h:outputText id="company" value="#{jobManagerBean.customer.company}"/></b>
                                </td>
                            </tr>
                            <tr>
                                <td>Person in-charge:</td>
                                <td><h:outputText id="name" value="#{jobManagerBean.customer.firstName} #{jobManagerBean.customer.lastName}"    /></td>
                            </tr>
                            <tr>
                                <td>Job type:</td>
                                <td>
                                    <h:selectOneMenu id="type" value="#{jobManagerBean.type}">
                                        <f:selectItem id="Normal" itemLabel="Normal Routine" itemValue="Normal Routine" />
                                        <f:selectItem id="New" itemLabel="New Routine" itemValue="New Routine" />
                                        <f:selectItem id="Event" itemLabel="Event" itemValue="Event" />
                                        <f:selectItem id="Rear" itemLabel="One-time" itemValue="One-time" />
                                    </h:selectOneMenu>
                                    <font class="fieldNote">*</font>
                                </td>
                            </tr>
                            <tr>
                                <td valign ="top">Description:</td>
                                <td>
                                    <table>
                                        <tr>
                                            <td> 
                                                <p:inputTextarea required="true" id="description" style="width:300px;height:100px;" effectDuration="400" requiredMessage="Description Required" value="#{jobManagerBean.description}"> 
                                                </p:inputTextarea> 
                                            </td>
                                            <td>
                                                <font class="fieldNote">*</font>
                                            </td>
                                        </tr>
                                    </table>



                                </td>
                            </tr>
                        </table>
                    </p:panel>
                    <p:panel header="Quotations" id="quotes">
                        <p:dataTable id="quotations" var="quotation" value="#{jobManagerBean.quotations}" paginator="false"                                     
                                     emptyMessage="No quotations found with given criteria."
                                     selectionMode="single" rowSelectListener="#{jobManagerBean.onRowSelect}"
                                     selection="#{jobManagerBean.selectedQuotation}">     
                            <p:column headerText="Date created"> 
                                <h:outputText value="#{quotation.creationDate}">
                                    <f:convertDateTime pattern="dd-MM-yyyy hh:mm a" 
                                    timeZone="#{defaultManagerBean.tz}"/>
                                </h:outputText>
                            </p:column> 
                            <p:column headerText="Amount involved"> 
                                <h:outputText value="#{quotation.totalAmount}">
                                    <f:convertNumber type="currency"/>
                                </h:outputText>
                            </p:column> 
                            <p:column headerText="Status"> 
                                <h:outputText value="#{quotation.status}" />                                             
                            </p:column> 
                            <p:column headerText="Remark"> 
                                <h:outputText value="#{quotation.remark}" />                                             
                            </p:column> 
                        </p:dataTable>
                        <p:commandButton id="btnAddForNewJob" value="Add a Quotation" 
                        	actionListener=	"#{jobManagerBean.addQuotation}"  update="addJob" ajax="true" /> 
                    </p:panel>
                    <table class="panel">
                         <tr>
                          <td class="btn">
                          <p:commandButton  id="btnDone" value="Done" actionListener="#{jobManagerBean.addJob}"  
                    update="error" ajax="true" /> 
                    </td>
                         </tr>
                        </table>
                    
                </h:form>
            </ui:define>
        </ui:composition>
    </body>
</html>
